#pragma once

#include "Dimension.h"


namespace uml {

const double Dimension::width_default_ = 0.0;
const double Dimension::height_default_ = 0.0;
void Dimension::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    width_ = json.value("width").toDouble(width_default_);
    height_ = json.value("height").toDouble(height_default_);
}

void Dimension::toJson(QJsonObject& json) {
    if (width_ != width_default_) {
        json.insert("width", width_);
    }
    if (height_ != height_default_) {
        json.insert("height", height_);
    }
}

/// <summary>
/// width getter
/// a real number (>=0) that represents a length along the x-axis.
/// </summary>
double Dimension::width() const {
    return width_;
}

/// <summary>
/// width setter
/// a real number (>=0) that represents a length along the x-axis.
/// </summary>
void Dimension::setWidth(double value) {
    width_ = value;
}

/// <summary>
/// height getter
/// a real number (>=0) that represents a length along the y-axis.
/// </summary>
double Dimension::height() const {
    return height_;
}

/// <summary>
/// height setter
/// a real number (>=0) that represents a length along the y-axis.
/// </summary>
void Dimension::setHeight(double value) {
    height_ = value;
}

} // namespace uml
